home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / _CREAT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  520 b   |  27 lines

  1. #include <stdio.h>
  2. #include <io.h>
  3. main()
  4. {
  5.     char fname[40], *p_fname;
  6.     int filehandle;
  7.     printf("Enter name of file to creat using"
  8.         "_creat:");
  9.     p_fname = gets(fname);
  10.  
  11. /* Creat the file using _creat */
  12.     if ( (filehandle = _creat(p_fname, 0)) == -1)
  13.     {
  14.         perror("Error creating file");
  15.         exit(0);
  16.     }
  17.     printf("File %s created. \n", fname);
  18.  
  19. /* Now close file */
  20.     if(_close(filehandle) != 0)
  21.     {
  22.         perror("Error closing file with _close");
  23.         exit(0);
  24.     }
  25.     printf("File %s closed. \n", fname);
  26. }
  27.